package com.itheima.tlias84.mapper;

import com.itheima.tlias84.dto.SelectClazzDTO;
import com.itheima.tlias84.entity.Clazz;
import com.itheima.tlias84.po.InsterClazzParam;
import com.itheima.tlias84.po.InsterEmpParam;
import com.itheima.tlias84.po.SelectClazzPageParam;
import com.itheima.tlias84.po.UpdateClazzParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {
    //分页查询
    List<SelectClazzDTO>selectClazzByPage(@Param("c") SelectClazzPageParam param);
    //根据id删除班级
    int deleteById(@Param("id") Integer id);
    //添加班级
    @Insert("insert into clazz(name,room,master_name,subject,begin_date,end_date,update_time) " +
            "values(#{c.name},#{c.room},#{c.masterName},#{c.subject},#{c.beginDate},#{c.endDate},#{c.updateTime})")
    int insertClazz(@Param("c") InsterClazzParam param);
    //根据id查询班级
   SelectClazzDTO selectClazzById(@Param("id") Integer id);
   //更新班级
    int updateClazz( UpdateClazzParam param);
    //查询所有班级
    @Select("select id,name,master_name,status,begin_date,end_date,update_time from clazz order by update_time desc")
    List<SelectClazzDTO> selectAll();
}
